import type { App } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import { setupRouterGuard } from './gurad'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/IndexView.vue'),
      meta: {
        title: 'router.home',
      },
    },
  ],
})

export const setupRouter = async (app: App) => {
  setupRouterGuard(router)
  app.use(router)
  await router.isReady()
}

export default router
